package com.canyinghao.cananimation;

import ohos.agp.animation.Animator;
import ohos.agp.animation.AnimatorProperty;
import ohos.agp.render.render3d.components.CameraComponent;
import ohos.agp.transition.Transition;
import ohos.agp.transition.TransitionComponents;
import ohos.agp.utils.Matrix;
import ohos.media.camera.device.Camera;

public class FlipAnimation extends Animator {

    private float mFromDegrees;
    private float mToDegrees;
    private CameraComponent mCamera;
    private float mCenterX;
    private float mCenterY;
    private boolean mIsX;
    private float mScale;


    public FlipAnimation(float fromDegrees, float toDegrees, float centerX, float centerY,  float scale) {
        mFromDegrees = fromDegrees;
        mToDegrees = toDegrees;
        mCenterX = centerX;
        mCenterY = centerY;
        mScale = scale;
        if (mScale <= 0) {
            mScale = 1;
        }
    }


    public void setIsX(boolean isX) {
        this.mIsX = isX;
    }

//    @Override
//    public void initialize(int width, int height, int parentWidth, int parentHeight) {
//        super.initialize(width, height, parentWidth, parentHeight);
//        mCamera = new CameraComponent();
//    }

//    @Override
//    protected void applyTransformation(float interpolatedTime, Transformation t) {
//
//        final float fromDegrees = mFromDegrees;
//        float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
//
//        final float centerX = mCenterX;
//        final float centerY = mCenterY;
//        final CameraComponent camera = mCamera;
//
//        final Matrix matrix = t.getMatrix();
//
//        camera.save();
//
//        if (mIsX) {
//            camera.rotateX(degrees);
//        } else {
//            camera.rotateY(degrees);
//        }
//
//
//        camera.getMatrix(matrix);
//        camera.restore();
//
//        matrix.preTranslate(-centerX, -centerY);
//        matrix.postTranslate(centerX, centerY);
//
//        matrix.preScale(mScale, mScale, centerX, centerY);
//
//
//    }

}
